var app = global.app,
    rootPath = app.rootPath,
    filePath = app.filePath,
    ossApi = require(rootPath + '/pkg/ossClient.js'),
    t = Date.now(),
    getBucketName = function () {
        return 'yoqu' + Math.floor(Math.random() * 5);
    };

module.exports = function (srcFileName, fileName, callback) {
    var Oss = new ossApi.OssClient({
            accessId:'zpAp1N9P2D6pqUaV',
            accessKey:'cTiGvZH01fbzV1DC5qgGgqzAlrNBJP',
            host:'oss-internal.aliyuncs.com'
        }),
        bucket = getBucketName();

    Oss.putObject(bucket, fileName, filePath + srcFileName, {}, function (err) {
        if (err) {
            callback({
                'error':1,
                'message':err.toString()
            });
            return;
        }
        console.log('oss upload time', Date.now() - t);
        callback({
            'error':0,
            'data':{
                uri:'http://' + bucket + '.oss.aliyuncs.com/' + fileName
            }
        });
    });
};